/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.utbm.tx52.stamp.ui.activity;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import fr.utbm.tx52.stamp.R;
import fr.utbm.tx52.stamp.logic.Contact;
import fr.utbm.tx52.stamp.ui.fragment.AddressBook;
import java.util.List;

/**
 * Class used to pick a contact from the Android Address Book
 *
 * @author GREA Antoine
 * @author TISSERAND Geoffrey
 */
public class ContactPicker extends FragmentActivity
{

	static List<Contact> selection;

	@Override
	public void onCreate(Bundle savedState)
	{
		super.onCreate(savedState);
		setContentView(R.layout.contact_chooser);

		final AddressBook addressBook = new AddressBook(true);
		FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
		fragmentTransaction.add(R.id.contact_chooser, addressBook);
		fragmentTransaction.commit();

		Button ok = new Button(this);
		ok.setText(R.string.ok);
		ok.setOnClickListener(new View.OnClickListener()
		{

			public void onClick(View v)
			{
				selection = addressBook.getAdapter().getSelected();
				finish();
			}
		});
		((LinearLayout) findViewById(R.id.contact_chooser)).addView(ok);
	}
}
